import './layout/init.js'
import gmUtil from "./utils/gmUtil.js";
import {eventEmitter} from "./model/EventEmitter.js";
import router from "./router.js";
import elUtil from "./utils/elUtil.js";
import goodsSale from "./page/goodsSale.js";

'use strict';
/**
 * 获取左侧菜单选中的标签
 * @returns {Promise<string>}
 */
const getLeftActiveLabel = async () => {
    const labelEl = await elUtil.findElement(".el-menu div>.router-link-exact-active.router-link-active")
    return labelEl.textContent.trim()
}

window.addEventListener('load', () => {
    console.log('卡世界页面加载完成')
    router.staticRoute();
    router.dynamicRouting();
    elUtil.findElement('.floating').then((el) => {
        el.remove();
        eventEmitter.send('el-msg', '已移除页面右下角悬浮广告')
    })
})

document.addEventListener('keydown', function (event) {
    if (event.key === "`") {
        eventEmitter.send('主面板开关')
    }
});

gmUtil.addGMMenu('主面板开关展示', () => {
    eventEmitter.send('主面板开关')
})

gmUtil.addGMMenu("获取当前产品页面列表", async () => {
    if (!goodsSale.isGoodsSalePage()) {
        //提示
        alert("当前页面不是产品管理");
        return;
    }
    const data = goodsSale.getPromotionCenterData();
    console.log("===========当前页面产品列表===========")
    console.log(data)
    console.log("===========当前页面产品列表===========")
    alert("已打印在控制台上")
})
